package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TestSysPaper;
import com.ruoyi.system.service.ITestSysPaperService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机组信息表Controller
 * 
 * @author ruoyi
 * @date 2025-09-23
 */
@Controller
@RequestMapping("/system/testsyspaper")
public class TestSysPaperController extends BaseController
{
    private String prefix = "system/testsyspaper";

    @Autowired
    private ITestSysPaperService testSysPaperService;

    @RequiresPermissions("system:testsyspaper:view")
    @GetMapping()
    public String testsyspaper()
    {
        return prefix + "/testsyspaper";
    }

    /**
     * 查询机组信息表列表
     */
    @RequiresPermissions("system:testsyspaper:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TestSysPaper testSysPaper)
    {
        startPage();
        List<TestSysPaper> list = testSysPaperService.selectTestSysPaperList(testSysPaper);
        return getDataTable(list);
    }

    /**
     * 导出机组信息表列表
     */
    @RequiresPermissions("system:testsyspaper:export")
    @Log(title = "机组信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TestSysPaper testSysPaper)
    {
        List<TestSysPaper> list = testSysPaperService.selectTestSysPaperList(testSysPaper);
        ExcelUtil<TestSysPaper> util = new ExcelUtil<TestSysPaper>(TestSysPaper.class);
        return util.exportExcel(list, "机组信息表数据");
    }

    /**
     * 新增机组信息表
     */
    @RequiresPermissions("system:testsyspaper:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存机组信息表
     */
    @RequiresPermissions("system:testsyspaper:add")
    @Log(title = "机组信息表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TestSysPaper testSysPaper)
    {
        return toAjax(testSysPaperService.insertTestSysPaper(testSysPaper));
    }

    /**
     * 修改机组信息表
     */
    @RequiresPermissions("system:testsyspaper:edit")
    @GetMapping("/edit/{paperId}")
    public String edit(@PathVariable("paperId") Long paperId, ModelMap mmap)
    {
        TestSysPaper testSysPaper = testSysPaperService.selectTestSysPaperByPaperId(paperId);
        mmap.put("testSysPaper", testSysPaper);
        return prefix + "/edit";
    }

    /**
     * 修改保存机组信息表
     */
    @RequiresPermissions("system:testsyspaper:edit")
    @Log(title = "机组信息表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TestSysPaper testSysPaper)
    {
        return toAjax(testSysPaperService.updateTestSysPaper(testSysPaper));
    }

    /**
     * 删除机组信息表
     */
    @RequiresPermissions("system:testsyspaper:remove")
    @Log(title = "机组信息表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(testSysPaperService.deleteTestSysPaperByPaperIds(ids));
    }
}
